package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: homechen
 * Date: 2024-03-23
 * Time: 18:51
 */
public class OuterClass1 {
    private int x = 10;

    public void outerMethod() {
        int y = 5;
        // 局部类部类
        class LocalInnerClass {
            public void innerMethod() {
                System.out.println("方法内部：" + y);
                System.out.println("方法外部: " + x);
            }
        }
        // 只能在方法内部使用
        LocalInnerClass inner = new LocalInnerClass();
        inner.innerMethod();
    }

    public static void main(String[] args) {
        OuterClass1 outerClass1 = new OuterClass1();
        outerClass1.outerMethod();
    }
}
